package edu.gatech.cs2340.sharks.fms.data;

/**
 * Status.java
 * @author Matthew Schauer
 * 
 * Allows passing of error messages
 */

import java.util.EnumMap;

public class Status
{
	public enum Code {OK, BAD_ARG, EXC, ERR, UNIMPL, BAD_LOGIN, ACCT_LOCK, NONE, EXISTS, DENIED, EXC_CLIPRO, EXC_IO, NO_CONN, NO_TAG, NOT_TAGGED, NET_FAIL, REQ_ERR, SRV_ERR, DB_ERR, SRV_SYN};
	static final EnumMap<Code, String>  messages;
	static
	{
		messages = new EnumMap<Code, String>(Code.class);
		messages.put(Code.OK, "OK");
		messages.put(Code.BAD_ARG, "An invalid argument was provided to a function.");
		messages.put(Code.EXC, "An exception was encountered during execution.");
		messages.put(Code.ERR, "An unknown error occurred during execution.");
		messages.put(Code.UNIMPL, "A function was called that has not been completely implemented yet.");
		messages.put(Code.BAD_LOGIN, "The login credentials provided are incorrect.");
		messages.put(Code.ACCT_LOCK, "The account you are trying to access is locked.  Contact an administrator to request an account unlock.");
		messages.put(Code.NONE, "The object you requested does not exist.");
		messages.put(Code.EXISTS, "An identical object already exists.");
		//messages.put(Code.DELETED, "The object you requested has been deleted.");
		messages.put(Code.DENIED, "You do not have sufficient privileges to perform the action you requested.");
		messages.put(Code.EXC_CLIPRO, "A client protocol exception occurred while making the request."); // TODO What exactly is this?  We can be more helpful.
		messages.put(Code.EXC_IO, "An I/O exception occurred while making the request.");
		messages.put(Code.NO_CONN, "The progrm could not connect to the server.  Check the status of your Internet connection.");
		messages.put(Code.NO_TAG, "The tag you requested does not exist.");
		messages.put(Code.NOT_TAGGED, "The item is not tagged with that tag.");
		messages.put(Code.NET_FAIL, "There was an error communicating over the network.");
		messages.put(Code.REQ_ERR, "The request to the server was invalid.");
		messages.put(Code.SRV_ERR, "An error occurred while the server was trying to process the request.");
		messages.put(Code.DB_ERR, "The server encountered an error while trying to query the database.");
		messages.put(Code.SRV_SYN, "There was a syntax error in the response from the server.");
	}
	
	private Code code;
	private String message;
	
	public Status(Code code) { this.code = code; message = messages.get(code); }
	public Status(Code code, String message) { this.code = code; this.message = message; }
	public Code code() { return code; }
	@Override
	public String toString() { return message; }
}
